import Person from './person';
class Teacher extends Person{
    constructor(_id,_name,_age,_klasses){
        super(_id,_name,_age);
        this.klasses = _klasses ;
    }
    outputKlasses(){
        let str = '';
        for(let item of this.klasses){
            str += ` ${item.number},`;
        }
        str = str.slice(0, -1);
        return super.introduce() + ` I am a Teacher. I teach Class${str}.`
    }
    introduce(){
        if(!this.klasses){//如果不存在班级
            return super.introduce() + ` I am a Teacher. I teach No Class.` ;
        }else{
            return this.outputKlasses();
        }
    }
    isTeaching(_student){
        for(let item of this.klasses)
            if(item.isIn(_student))
                return true ;
        return false ;
    }
}
module.exports = Teacher ;